package cn.zyy.jdbc;

import cn.zyy.utils.JDBCUtil;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCMemo06 {
    public static void main(String[] args) {
        Connection conn = null;
        Statement stmt = null;
        try {
            conn = JDBCUtil.getConnection();
            //3、生成操作数据库的对象
            stmt = conn.createStatement();
            //4、编写SQL 发送SQL DML insert delete update
            String sql = "update user set username = '张三',pwd = '666666',role = 2 where id = 15";
            System.out.println("sql = " + sql);
            //5、处理结果集
            //影响的行数
            int line = stmt.executeUpdate(sql);
            System.out.println("line = " + line);
        }catch (Exception e) {
            e.printStackTrace();
        } finally {
            //6、释放资源
            JDBCUtil.closeAll(null,stmt,conn);
        }
    }
}
